<?php
class Photo extends BasePhoto
{
    protected static $instance;

    public static function GetInstance()
    {
        return self::$instance ? self::$instance : self::$instance = new Photo();
    }

    public function GetConfig()
    {
        return AppConfig::GetInstance();
    }

    protected function LoadSizes()
    {
        $this->SIZE_TINY = new Size(75, 75);
        $this->SIZE_THUMB = new Size(120, 120);
        $this->SIZE_SMALL = new Size(240, 240);
        $this->SIZE_MEDIUM = new Size(500, 500);
        $this->SIZE_LARGE = new Size(700, 700);
    }

    public function SaveUploadedPhoto()
    {
        $photoId = $this->GenerateId();
        return FileHandler::SaveUploadedFile($this->dirOrigin, $photoId);
    }

    protected function GenerateId()
    {
        $user_id = $this->config->GetUserModel()->GetCurrentUserId();
        $ext = FileHandler::GetExt($_FILES['Filedata']['name']);
        $time = microtime(true);
        return "{$time}_$user_id.$ext";
    }
}
?>
